﻿using IQIGame.Onigao.Framework;

namespace IQIGame.Onigao.GamePlay
{
    public class LoadingModule : Singleton<LoadingModule>
    {
        public enum LoadingType
        {
            None = 0,
            CommonUI = 1,
            MainCity = 2,
            Level = 3,
            Battle = 4,
        }

        public ILoadingController current;

        private LoadingModule()
        {

        }

        public void StartLoading(LoadingType type)
        {
            if (current != null)
            {
                return;
            }
            switch (type)
            {
                case LoadingType.CommonUI:
                case LoadingType.Level:
                    current = ClassPool.Get<CommonLoadingUIController>();
                    break;
                case LoadingType.MainCity:
                    current = ClassPool.Get<CommonLoadingUIController>();
                    break;
                case LoadingType.Battle:
                    current = ClassPool.Get<CommonLoadingUIController>();
                    //current = ClassPool.Get<BattleEffectLoading>();
                    break;
                default:
                    break;
            }
            current?.Start();
        }

        public void EndLoading()
        {
            if (current != null)
            {
                ClassPool.PutAutoType(current);
                current = null;
            }
        }
    }
}
